var searchParams;


//Table表格数据源
var configTable = $('#config_table').datagrid(BasicData.createDatagrid({
	url : '',
	checkOnSelect : true,
	singleSelect : true,
	selectOnCheck : true,
	frozenColumns : [ [ {
		field : 'ck',
		checkbox : true
	}, {
		title : 'BUSINESS_CONFIG_ID',
		field : 'BUSINESS_CONFIG_ID',
		hidden : true
	} ] ],
	columns : [ [ {
		field : 'IS_ASSOCIATOR_DICTEXT',
		title : '是否开启会员',
		width : '20%',
		sortable : true,
		align : 'center'
	}, {
		field : 'NOTES',
		title : '会员备注',
		width : '80%',
		sortable : true,
		align : 'center'
	}] ],
	onDblClickRow:function(rowIndex, rowData){
	
	},
	 onClickRow : function(index, row){

	 }
}));
	$(function() {
		//会员开启、关闭事件
		$('#editHy').on('click', function() {
			var node = configTable.datagrid('getSelected');
			if (node) {
				editHY(node.BUSINESS_CONFIG_ID);
			} else {
				layer.msg('请选择一条数据！', {
					time : 1000
				})
			}
		});
		//修改按钮事件
		$('#editConfig').on('click', function() {
			var node = configTable.datagrid('getSelected');
			if (node) {
				editConfig(node.BUSINESS_CONFIG_ID);
			} else {
				layer.msg('请选择一条数据！', {
					time : 1000
				})
			}
		});
	
	//编辑打开窗体
	function editConfig(BUSINESS_CONFIG_ID) {
		parent.layer.open({
			title : '修改',
			type : 2,
			btn : [ '保存', '关闭' ],
			yes : function(index, layero) {
				var iframeWin = parent.window[layero.find('iframe')[0]['name']];
				iframeWin.parentIframeName = window.name;
				
				iframeWin.$("#configForm").submit();
			},
			btn2 : function(index, layero) {
			},
			area : [ '50%', '50%' ],
			content : rootpath + '/business/toEditConfig.do?BUSINESS_CONFIG_ID=' + BUSINESS_CONFIG_ID
		});
	}
	//禁用
	function editHY(BUSINESS_CONFIG_ID){
		$.ajax({
			cache : true,
			type : "POST",
			url : rootpath + '/business/edithy.do',
			data : {
				BUSINESS_CONFIG_ID : BUSINESS_CONFIG_ID
			},
			async : false,
			success : function(data) {
				layer.msg('成功！', {
					icon : 1,
					time : 1000
				}, function() {
					//刷新列表
					configTable.datagrid('reload');
				})
			}
		});
	}
})